package com.ch.chatbot.interfaces.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ch.chatbot.domain.common.Result;
import com.ch.chatbot.domain.model.po.QuestionEntity;
import com.ch.chatbot.domain.service.IQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chenhao
 * @date 2023-03-22 20:12:22
 *
 * @description 
 */
@Slf4j
@RestController
@RequestMapping("/question")
@Api(value = "question", tags = "管理模块")
public class QuestionController {

    @Autowired
    private IQuestionService questionService;


    /**
     * 分页查询
     * @param page 分页对象
     * @param questionEntity 
     * @return Result
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    public Result getQuestionPage(Page page, QuestionEntity questionEntity) {
        return Result.ok(questionService.page(page, Wrappers.query(questionEntity)));
    }


    /**
     * 通过id查询
     * @param id id
     * @return Result
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    public Result getById(@PathVariable("id") Integer id) {
        return Result.ok(questionService.getById(id));
    }
}